package eu.simrun;

import java.util.LinkedList;
import java.util.List;

/**
 * 测试线程
 * 
 * @author wzz
 * 
 */
public final class RunProcess{

	List<RunTask> tasks = new LinkedList<RunTask>();
	
	void run() {
		for(RunTask task:tasks) {
			RunResult res = null;
			try {
				res = task.doTask();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (res!=null)
				System.out.println(RunResult.LEVEL.LEVEL_DETAIL[res.getLevel()]+" "+res.getMessage());
		}
	}

	public void addTask(RunTask task, int repeatTime) {
		while(repeatTime>0) {
			tasks.add(task);
			repeatTime--;
		}
	}
	
	public void addTask(RunTask task) {
		tasks.add(task);
	}
}
